﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Controls_ModalPopupMessage : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }

    /// <summary>
    ///     Display the Modal Popup
    /// </summary>
    /// <param name="Title"></param>
    /// <param name="Message"></param>
    /// <param name="Mode">Successful: 1, Failed: 2, Normal: 0</param>
    public void ShowModalPopup(string Title, string Message, int Mode)
    {
        lblModalPopupTitle.Text = Title;

        switch (Mode)
        {
            case 0: // NOTIFICATION
                lblModalPopupMessage.Text = "<span class='notificationMessage'>" + Message + "</span>";
                break;
            case 1: // SUCCESSFUL MESSAGE
                lblModalPopupMessage.Text = "<span class='successfulMessage'>" + Message + "</span>";
                break;
            case 2: // FAILED MESSAGE
                lblModalPopupMessage.Text = "<span class='failedMessage'>" + Message + "</span>";
                break;
        }

        ModalPopupMessage.Show();
    }


    protected void btnModalPopupOK_Redirect_Click(object sender, CommandEventArgs e)
    {
        Response.Redirect(e.CommandArgument.ToString());
    }

    /// <summary>
    ///     Display the Modal Popup and Redirect the user to the desired URL when Close button is clicked
    /// </summary>
    /// <param name="Title"></param>
    /// <param name="Message"></param>
    /// <param name="Mode">Successful: 1, Failed: 2, Normal: 0</param>
    /// <param name="RedirectURL">Redirect URL</param>
    public void ShowModalPopup_Redirect(string Title, string Message, int Mode, string RedirectURL)
    {
        lblModalPopupTitle_Redirect.Text = Title;

        switch (Mode)
        {
            case 0: // NOTIFICATION
                lblModalPopupMessage_Redirect.Text = "<span class='notificationMessage'>" + Message + "</span>";
                break;
            case 1: // SUCCESSFUL MESSAGE
                lblModalPopupMessage_Redirect.Text = "<span class='successfulMessage'>" + Message + "</span>";
                break;
            case 2: // FAILED MESSAGE
                lblModalPopupMessage_Redirect.Text = "<span class='failedMessage'>" + Message + "</span>";
                break;
        }

        btnModalPopupOK_Redirect.CommandArgument = RedirectURL;

        ModalPopupMessage_Redirect.Show();
    }
}
